import 'package:flutter/material.dart';
import '../theme/theme_color.dart';

showInputDialog(BuildContext context, Function(String) callback) {
  showDialog(context: context, builder: (builder) {
    final controller = TextEditingController();
    return Container(
      decoration: ShapeDecoration(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(8),
        ),
        color: Colors.white
      ),
      child: Column(
        children: [
          Container(
            margin: const EdgeInsets.only(left: 20.0, top: 8.0, right: 20.0),
            padding: const EdgeInsets.all(12),
            decoration: ShapeDecoration(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(4)
                ),
                color: const Color(0xFFF9F9F9)
            ),
            child: TextField(
              keyboardType: TextInputType.text,
              cursorColor: ThemeColor.mainColor,
              style: TextStyle(
                fontSize: 12,
                color: ThemeColor.textColor,
              ),
              maxLines: 5,
              controller: controller,
              decoration: InputDecoration(
                  hintText: "请输入...",
                  isCollapsed: true,
                  border: InputBorder.none,
                  hintStyle: TextStyle(color: ThemeColor.textColorSecond),
              ),
            ),
          ),
          Row(
            children: [
              GestureDetector(
                onTap: () {
                  Navigator.of(context).pop();
                },
                child: Container(
                  height: 48,
                  alignment: Alignment.center,
                  child: Text(
                    "取消",
                    style: TextStyle(
                      color: ThemeColor.textColorSecond,
                      fontSize: 16
                    ),
                  ),
                ),
              ),
              Container(
                height: 48,
                width: 1,
                color: ThemeColor.dividerColor,
              ),
              GestureDetector(
                onTap: () {
                  callback(controller.text);
                  Navigator.of(context).pop();
                },
                child: Container(
                  height: 48,
                  alignment: Alignment.center,
                  child: Text(
                    "确定",
                    style: TextStyle(
                        color: ThemeColor.textColor,
                        fontSize: 16
                    ),
                  ),
                ),
              )
            ],
          )
        ],
      ),
    );
  });
}